package org.example;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

import static org.example.dbTest.*;

//TIP 要<b>运行</b>代码，请按 <shortcut actionId="Run"/> 或
// 点击装订区域中的 <icon src="AllIcons.Actions.Execute"/> 图标。
public class Main {
    public static void main(String[] args) {
        //TIP 当文本光标位于高亮显示的文本处时按 <shortcut actionId="ShowIntentionActions"/>
        // 查看 IntelliJ IDEA 建议如何修正。
        System.out.printf("Hello from jdbc and welcome!\n");
        String url = "jdbc:mysql://localhost:3306/test?useSSL=false&serverTimezone=UTC";
        String username = "root";
        String password = "123456";

        try {
            Connection c = DriverManager.getConnection(url, username, password);
            System.out.println("数据库连接成功！");

        } catch (SQLException e) {
            System.out.println("数据库连接失败");
            e.printStackTrace();
        }
        try {
            tableTest();
            System.out.println("\n------- start crud test------");
            add("lisa",3,"yf204","2005-07-03");
            System.out.println("\n -------result after add ---------");
            listAll();
            update();
            System.out.println("\n -------result after update---------");
            delete();
            System.out.println("\n -------result after delete---------");

        }
        catch (Exception e) {
            e.printStackTrace();
        }



    }
}